package edu.ptu.springboot04.common.controller;

import lombok.AllArgsConstructor;

/**
 * @BelongsProject: springboot04
 * @BelongsPackage: edu.ptu.springboot04.common.controller
 * @Author: HYJ
 * @CreateTime: 2025-03-20  21:10
 * @Description: TODO
 * @Version: 1.0
 */
@AllArgsConstructor
public class BaseController {
    // 返回一个TableDataInfo对象，包含状态码、消息、总记录数和行数据
    protected TableDataInfo dataTable(Object rows, Long total) {
        return new TableDataInfo(200, "success", total, rows);
    }

    // 返回一个TableDataInfo对象，包含状态码、消息、总记录数和行数据，根据flag的值判断状态码和消息
    protected TableDataInfo toJson(boolean flag, Object rows, Long total) {
        return new TableDataInfo(
                flag ? 200 : 500,
                flag ? "success" : "fail",
                total,
                rows);
    }
}
